package com.lh.java.basic.datatype;


/**
 ************************************************
 ** Module : 面向过程使用数组的弊端
 ** Date: 2012-7-31  Time: 下午02:42:00 
 ** Author lh 
 ************************************************ 
 */
public class TestProcedureOrientedArray {
	public static void main(String[] args) {
		long[] arr;
		arr=new long[100];
		int nElems = 10;
		int j;
		arr[0]= 77;
		arr[1]= 44;
		arr[2]= 99;
		arr[3]= 55;
		arr[4]= 22;
		arr[5]= 88;
		arr[6]= 11;
		arr[7]= 00;
		arr[8]= 33;
		arr[9]= 10;
		//显示数据
		for(j=0;j<nElems;j++){
			System.out.print(arr[j]+" ");
		}
		System.out.println();
		
		//查找		
		long searchKey = 66;
		for(j=0;j<nElems;j++){
			if(arr[j]== searchKey){
				break;
			}
		}
		if(j==nElems){
				System.out.println("can't find key "+searchKey);
			}else {
				System.out.println("find search key "+ searchKey);
		}
		
        //删除 
		searchKey = 55;
		for(j=0;j<nElems;j++){
			if(arr[j]== searchKey){
				break;
			}
		}
		for(int k=j;k<nElems;k++){
			arr[k]=arr[k+1];
		}
		nElems--;
		
		//显示数据
		for(j=0;j<nElems;j++){
			System.out.print(arr[j]+" ");
		}
		System.out.println();
	}

}
